from flask import Flask, render_template, request, jsonify

app = Flask(__name__)

@app.route('/')
def hello_world():
    threadInfo = getData("/home/fighter/IdeaProjects/SSDBWeekendTest/threadSpeed.log")
    threadInfo2 = getData("/home/fighter/IdeaProjects/SSDBWeekendTest/per2kwSpeed.log")

    return render_template("index.html", threadInfo=(threadInfo), threadInfo2=threadInfo2)

def getData(filePath):
    threadNames = []
    threadSpeed = []
    threadInfo = {}

    with open(filePath) as f:
        for line in f.readlines():
            line = line.replace('\n', '').split(':')
            name = ':'.join(line[:-1])
            speed = line[-1]
            threadNames.append(name)
            threadSpeed.append(speed)

    threadInfo['names'] = threadNames
    threadInfo['speeds'] = threadSpeed

    return threadInfo


if __name__ == '__main__':
    app.run(host='192.168.11.97', debug=True)
